package com.teamwork.shareplatform.mapper;

import com.teamwork.shareplatform.entity.Subject;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SubjectMapper {
    // 查询所有科目
    @Select("SELECT * FROM subjects")
    List<Subject> queryAll();

    // 查询层级为 0 的科目
    @Select("SELECT * FROM subjects WHERE level = 0")
    List<Subject> queryByLevel();

    // 根据父科目 ID 查询子科目
    @Select("SELECT * FROM subjects WHERE parent = #{id}")
    List<Subject> queryByParent(int id);
}
